<?php
/**
* phpCan - http://idc.anavallasuiza.com/
*
* phpCan is released under the GNU Affero GPL version 3
*
* More information at license.txt
*/

defined('ANS') or die();

if ($Vars->getRoute(0, 'login')) {
	return;
}

$cookie = $Vars->getCookie('admin_session_auth');

foreach ((array)$Config->admin_users as $user_name => $user_config) {
	if ($cookie == md5($user_name.$user_config['password'])) {
		$logged_user = $user_name;
		return;
	}
}

redirect(path('login'));
?>